import sys

with open(sys.argv[1],'r',encoding='utf-8') as f:
    old_html=f.readlines()

with open(sys.argv[1],'w',encoding='utf-8') as f:
    for line in old_html:
        is_header=1
        if is_header==1:
            if '<meta charset="UTF-8">' in line:
                line='<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1">\n<link rel="stylesheet" href="../css/github-markdown.css">\n'
            elif '.task-list-item { list-style-type: none; } .task-list-item-checkbox { margin-left: -20px; vertical-align: middle; }' in line:
                line=''
            elif line.isspace():
                line=''
            elif '<style>' in line:
                line=''
            elif '</style>' in line:
                line=''
            elif '</head>' in line:
                line="""
<style>
	.markdown-body {
		box-sizing: border-box;
		min-width: 200px;
		max-width: 980px;
		margin: 0 auto;
		padding: 45px;
	}

	@media (max-width: 767px) {
		.markdown-body {
			padding: 15px;
		}
	}
</style>
</heade>

"""
            elif '<body class="vscode-body vscode-light">' in line:
                is_header=0
                line='<body class="markdown-body">\n\n'
        f.write(line)
